package com.wanxi.feign;

import com.wanxi.dto.NewsDTO;
import com.wanxi.model.NewsQuery;
import com.wanxi.model.entity.News;
import com.wanxi.result.CommonResult;
import io.swagger.annotations.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "news-server",path = "/news")
public interface NewsFeignClient {

    @ApiOperation(value = "查询新闻")
    @ApiResponses({
            @ApiResponse(code = 200,message = "OK",response = NewsDTO.class,responseContainer = "List")
    })
    @GetMapping("/findNews")
    public CommonResult findNews(@SpringQueryMap NewsQuery newsQuery);


    @ApiOperation(value = "新增新闻",response = CommonResult.class)
    @PostMapping("/addNews")
    public CommonResult addNews(@RequestBody NewsDTO news);


    @ApiOperation(value = "修改新闻",response = CommonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "新闻编号",required = true),
    })
    @PutMapping("/updateNews")
    public CommonResult updateNews(@RequestParam("id") Long id, @RequestBody NewsDTO news);

    @ApiOperation(value = "新闻停启用")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "新闻编号",required = true),
            @ApiImplicitParam(name = "state",value = "状态",required = true)
    })
    @PutMapping("/updateNewsState")
    public CommonResult updateNewsState(@RequestParam("id") Long id, @RequestParam("state") Integer state);

    @ApiOperation(value = "后台查询新闻")
    @ApiResponses({
            @ApiResponse(code = 200,message = "OK",response = News.class,responseContainer = "List")
    })
    @GetMapping("/findNewsBack")
    public CommonResult findNewsBack(@SpringQueryMap NewsQuery newsQuery);
}
